package com.eveinfo.display.asset;

import android.app.Activity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ViewFlipper;

import com.eveinfo.R;
import com.eveinfo.sql.DataBaseHelper;
import com.eveinfo.sql.data.Item;
import com.eveinfo.sql.data.ItemAttributes;
import com.eveinfo.tools.EveInfoPreferences;
import com.eveinfo.tools.MyGestureDetector;
import com.eveinfo.tools.Tools;

public class ItemInfoView extends Activity {

	private Item item;
	private ItemAttributes itemAttributes;
	private GestureDetector gestureDetector;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.ship);
		
		int typeID = getIntent().getIntExtra("typeID", -1);
		if(typeID == -1){
			return;
		}
		
		final DataBaseHelper dataBaseHelper =  new DataBaseHelper(this);
		dataBaseHelper.openDataBase();
		item = dataBaseHelper.getItem(typeID);
		itemAttributes = dataBaseHelper.getItemAttributes(typeID);
		dataBaseHelper.close();

		ImageView picture = (ImageView) findViewById(R.id.IVShip);
		picture.setImageDrawable(Tools.getItemPicture(item, EveInfoPreferences.ASSETS_IMAGE_SIZE_64));

		TextView titleTV = (TextView) findViewById(R.id.TVShip);
		titleTV.setText(item.getTypeName());

		ViewFlipper viewFlipper = (ViewFlipper) findViewById(R.id.VFShip);
		viewFlipper.addView(getDescriptionView());
		
		gestureDetector = new GestureDetector(new MyGestureDetector(this, viewFlipper));

	}

	private View getDescriptionView(){
		TextView textView = new TextView(this);
		textView.setText(item.getDescription());
		
		return textView;
	}
	
}
